package org.emergent.lucidity.test;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;

public class RhinoEnvironment extends LucidScriptableObject
{
    // The zero-argument constructor used by Rhino runtime to create instances
    public RhinoEnvironment() { }

    // Method jsConstructor defines the JavaScript constructor
    public void jsConstructor() {}

    public void jsFunction_logimpl(int level, String input)
    {
        System.out.println( input );
    }
    
    public String jsFunction_loadRes(String filename)
    {
        return MultiTool.loadSampleAsString( filename );
    }

    public static void inject(Context cx, Scriptable scope) throws Exception
    {
        defineClass(scope, RhinoEnvironment.class);
        Object[] arg = { };
        Scriptable myCounter = cx.newObject(scope, "RhinoEnvironment", arg);
        scope.put("lucidenv", scope, myCounter);
    }
}